#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        int left = 0;
        int ret = 0;
        if (nums.size() < 2) return nums.size();
        for (int i = 0;i < nums.size() - 1;i++)
        {
            int right = nums[i + 1] - nums[i];
            if (right == 0) continue;
            if (left * right <= 0) ret++;
            left = right;
        }
        return ret + 1;
    }
};